<?
session_start();
require_once "funcoes.php";

VerificaAcesso("usuario.php");

include("conexao.php");

$idUsuario = $_SESSION[__id_usuario];

if (isset($idUsuario)) {
	//seleciona os dados
	$select = "
	select id_usuario, nome, login_usuario, senha, email
	from   secitec.usuarios
	where  id_usuario = '$idUsuario'
	";

	$query = pg_exec($conexao, $select);
	if (pg_num_rows($query) > 0) {
		$dado = pg_fetch_row($query);
		$idUsuario = $dado[0];
		$dado[5] = $dado[3];
	}

} else {

include ("cabecalho.php");

echo '<table style=" position: absolute;  margin: 30px 0px 10px 90px;"><tr><td>';

}

?>
<script>
function mascara(o,f){
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}

function execmascara(){
    v_obj.value=v_fun(v_obj.value)
}

function user(v){
    dominio=v
    caminho=""
    if(v.indexOf("/")>-1)
        dominio=v.split("/")[0]
    dominio=dominio.replace(/[^\w\.\+-]/g,"")
    v=""+dominio+caminho
    return v
}

function valida_senha (frm)
{
    if (frm.senha.value != frm.senh4.value)
    {
        alert ("A senha nao confere.");
        return false;
    }
}
</script>

<div style=" position: relative; width: 500px; margin-left: 50px; align: center; border: 0;">
<form id="frmUsuario" name="frmUsuario" action="cadastros/cadUsuario.php" onsubmit="return valida_senha(this)" method="post">
 <small>

<div align="center" style="color: #0362A6; border-bottom: 2px solid #0362A6;"><big>Cadastro de Usu&aacute;rio</big></div><br><br>

<!-- Nome do Inscrito -->
<div class="titulo-assunto"> Nome</div><br>
&nbsp;&nbsp;&nbsp; <input type="text" name="nome" class="validar naonulo" alt="Nome" size="55" maxlength="70" value="<?= $dado[1]?>"><br><br>

<!-- Dados do Usuario -->
<div class="titulo-assunto"> Login: <span style="margin-left: 160px" > Senha:</span> <span style="margin-left: 80px" >Confirma Senha:</span></div><br>
&nbsp;&nbsp;&nbsp; <input onkeyup="mascara(this,user)" type="text" name="login" class="validar naonulo" alt="Login" size="25" maxlength="25" value="<?= $dado[2]?>">
<span style="margin-left: 30px" ><input onkeyup="mascara(this,user)" type="password" name="senha" class="validar naonulo" alt="Senha" size="13" maxlength="8" value="<?= $dado[3]?>"></span>
<span style="margin-left: 30px" ><input onkeyup="mascara(this,user)" type="password" name="senh4" class="validar naonulo" alt="Senha" size="13" maxlength="8" value="<?= $dado[5]?>"></span><br><br>

<!-- Email -->
<div class="titulo-assunto"> Email: </div><br>
&nbsp;&nbsp;&nbsp; <input type="text" name="email" class="validar" alt="E-mail" size="55" maxlength="70" value="<?= $dado[4]?>"><br><br>

<input type="hidden" name="idUsuario" value="<?=$dado[0]?>" class="input-button" />
<input class="input-button" name="submit" TYPE="submit" VALUE="Salvar" />
<input class="input-button" name="reset" TYPE="reset" VALUE="Limpar" />
</small></form>
</div>

<?
if (!isset($idUsuario)) {

echo '</td></tr></table>
</div>
</body>
</html>';

}

